﻿using CommunityToolkit.Mvvm.ComponentModel;
using GameView.Comment;
using System.ComponentModel.DataAnnotations;

namespace GameView.Services.Dtos
{
    public partial class WithdrawalRecords : ObservableValidator
    {
        [ObservableProperty]
        private bool _isSelected;

        [ObservableProperty]
        private int _id;
        /// <summary>
        /// 订单号
        /// </summary>
        [ObservableProperty]
        [Required(ErrorMessage = "订单号不能为空")]
        [MaxLength(50, ErrorMessage = "订单号最大长度50")]
        private string _orderNumber = string.Empty;

        /// <summary>
        /// 订单状态 (2001:待处理, 3002:处理中, 2003:已完成, 2004:已忽略)
        /// </summary>
        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(OrderStatusDisplay))]
        [NotifyPropertyChangedFor(nameof(ShowActionButton))]
        [NotifyPropertyChangedFor(nameof(ShowAccontErrorButton))]
        [NotifyPropertyChangedFor(nameof(ShowWaitButton))]
        private int _orderStatus = 2001;

        public string OrderStatusDisplay => OrderStatus.GetDisplay();

        /// <summary>
        /// 提现时间
        /// </summary>
        [ObservableProperty]
        private string _withdrawalTime = string.Empty;

        /// <summary>
        /// 项目名称
        /// </summary>
        [ObservableProperty]
        [Required(ErrorMessage = "项目名称不能为空")]
        private string _projectName = string.Empty;

        /// <summary>
        /// 游戏名称
        /// </summary>
        [ObservableProperty]
        [Required(ErrorMessage = "游戏名称不能为空")]
        private string _gameName = string.Empty;

        /// <summary>
        /// 角色名称
        /// </summary>
        [ObservableProperty]
        [Required(ErrorMessage = "角色名称不能为空")]
        private string _characterName = string.Empty;

        /// <summary>
        /// 发货人
        /// </summary>
        [ObservableProperty]
        private string _merchant = string.Empty;
        /// <summary>
        /// 付款方式 (5001:银行卡, 5002:支付宝, 5003:微信)
        /// </summary>
        [ObservableProperty]
        private string _paymentMethodsStr = string.Empty;
        [ObservableProperty]
        private string _userCodeNum = string.Empty;
        ///// <summary>
        ///// 付款方式 (5001:银行卡, 5002:支付宝, 5003:微信)
        ///// </summary>
        //[ObservableProperty]
        //[NotifyPropertyChangedFor(nameof(PaymentMethodsDisplay))]
        //private int _paymentMethods = 5001;

        //public string PaymentMethodsDisplay => PaymentMethods.GetDisplay();

        /// <summary>
        /// 货币金额
        /// </summary>
        [ObservableProperty]
        [Range(0, uint.MaxValue, ErrorMessage = "金额无效")]
        private uint _monetaryAmount;

        /// <summary>
        /// 提现金额
        /// </summary>
        [ObservableProperty]
        [Range(0, uint.MaxValue, ErrorMessage = "金额无效")]
        private uint _withdrawalAmount;

        /// <summary>
        /// 货币余额
        /// </summary>
        [ObservableProperty]
        private int _currencyBalance;

        /// <summary>
        /// 银行账号
        /// </summary>
        [ObservableProperty]
        [MaxLength(50, ErrorMessage = "银行账号最大长度50")]
        private string _bankCode = string.Empty;

        /// <summary>
        /// 账号姓名
        /// </summary>
        [ObservableProperty]
        [MaxLength(50, ErrorMessage = "账号姓名最大长度50")]
        private string _bankName = string.Empty;

        /// <summary>
        /// 机器码
        /// </summary>
        [ObservableProperty]
        private string _machineCode = string.Empty;

        public bool ShowActionButton => OrderStatus == 2001 || OrderStatus == 2002;
        public bool ShowAccontErrorButton => OrderStatus == 2001;
        public bool ShowWaitButton => OrderStatus == 2001;
    }
}